using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Data.Models.Mapping
{
    public class ContactMap : EntityTypeConfiguration<Contact>
    {
        public ContactMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Code)
                .HasMaxLength(40);

            this.Property(t => t.ContactName)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.Email)
                .HasMaxLength(50);

            this.Property(t => t.Description)
                .HasMaxLength(1000);

            this.Property(t => t.PostAttention)
                .HasMaxLength(250);

            this.Property(t => t.PostAddress)
                .HasMaxLength(1000);

            this.Property(t => t.PostCity)
                .HasMaxLength(250);

            this.Property(t => t.PostCountry)
                .HasMaxLength(40);

            this.Property(t => t.Tel_Num)
                .HasMaxLength(40);

            this.Property(t => t.Fax_Num)
                .HasMaxLength(40);

            this.Property(t => t.Website)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Contacts");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.ContactName).HasColumnName("ContactName");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.PostAttention).HasColumnName("PostAttention");
            this.Property(t => t.PostAddress).HasColumnName("PostAddress");
            this.Property(t => t.PostCity).HasColumnName("PostCity");
            this.Property(t => t.PostCountry).HasColumnName("PostCountry");
            this.Property(t => t.Tel_Num).HasColumnName("Tel_Num");
            this.Property(t => t.Fax_Num).HasColumnName("Fax_Num");
            this.Property(t => t.Website).HasColumnName("Website");
        }
    }
}
